package com.yatong.commons;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author GD
 * @Date 2018/10/18.
 * @Description:
 */
//@Configuration
public class UploadFilePathConfig extends WebMvcConfigurerAdapter {

    @Value("${file.staticAccessPath}")
    private String staticAccessPath;
    @Value("${file.uploadFolder}")
    private String uploadFolder;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//
//        registry.addResourceHandler("/css/**").addResourceLocations("classpath:/META-INF/resources/")
//                .addResourceLocations("classpath:/resources/").addResourceLocations("classpath:/static/");


        //文件磁盘图片url 映射
        //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径/upload/**
        registry.addResourceHandler("/excel/**").addResourceLocations("file:" + uploadFolder);
        super.addResourceHandlers(registry);
    }
}